|
|
|
|
|
|
|
One of the easiest things to change in an application that would affect size and speed are the static resources the application uses. Every time you use a string constant for messages or labels, it increases the size of the application, as do picture resources used by the application. If the picture resources are loaded rather than included in the application, the load process also affects the application's speed. All these items are collectively called application resources and can be defined in a resource definition file. |
|
|
|
|
|
|
|
|
Resources are the presentation data that your application usesthat is, no matter what your application does, it uses resources to interact with users. You can divide resources into two main groups: string and binary. String resources contain text string data, such as Hello World or (more realistically) Cannot find Name in Address Book!. Binary resources can contain icons, bitmaps, cursors, sounds, videos, or any other data that's usually stored as binary information. |
|
|
|
|
|
|
|
|
Using a resource file allows you to collect into one file all the version-specific text, bitmaps, and sounds for an application. This information is kept separate from the code, allowing better control over them. In addition to the obvious optimization effects, resource files are also used to give the application the capability to change its strings, pictures, fonts, sounds, and so on, depending on user input. |
|
|
|
|
|
|
|
|
A good example for using resource files is when an application is sold in other countries. When an application is distributed in another country, it should display words and images in that country's language. Rather than rewrite the application for each country, you can have a resource file that contains the different country-specific information and then, depending on an installation prompt, uses the correct file. |
|
|
|
|
|
|
|
|
A resource file is nothing more than a plain text file that consists of the following: |
|
|
|
|
|
|
|
|
By using these commands, you can take most of your memory-intensive resources and define them into a single resource definition file (.RC) and compile them with the actual resource files into a single binary (.RES) file by using the Resource compiler. |
|
|
|
|
|
|
|
|
Note The Resource compiler is included on VB's product CD-ROM in the COMMON/TOOLS/VB/RESOURCE directory. You only need to copy the contents to your hard drive to use it. |
|
|
|
|
|
|